<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>

/*function foo() {
    var innerMessage='inner';

  return   function () {
        alert(innerMessage)
    }
}

var boo = foo();
var func = boo();
boo=null;
func();*/


function createFunctions() {

    var result = new Array();

    for (var i=0;i<10;i++){
        result[i] = function (num) {
          return  function () {
              return num;
           }
        }(i);
    };

    return result;
}


var num = createFunctions()[3]();

alert(num);
</script>
</html>